﻿// ==UserScript==
// @name ISP_2ParentSSH
// @description Add button to open SSH for parent server for service
// @author yumaa@ispsystem.com
// @include */manager/billmgr*
// ==/UserScript==

(function() {
if ( ! /manager.*billmgr/.test(window.location) ) return;

	opera.addEventListener('BeforeEvent.DOMContentLoaded', function(e) {
		if ( ! ujsCheckPage(Array('parent','title')) ) return;
		
		if ( document.frm && document.frm.server ) {
			var srv = document.frm.server.options[document.frm.server.selectedIndex].text;
			
			var titl = $id('fieldsDiv').getElementsByClassName('field-title');
			for (var i = 0; i < titl.length; i++) {
				if ( 'Обслуживающий сервер' == titl[i].innerText ||
					 'Applied server' == titl[i].innerText ||
					 'Associated server' == titl[i].innerText ||
					 'Service server' == titl[i].innerText ) {
				
					titl = titl[i];
					break;
				}
			}
			titl.innerHTML += "<br><a href='ssh:"+srv+"'>ssh</a> <a href='clip:"+srv+"'>copy</a>";
		}
		
	}, true);
})();
